@import "../core/exports";
@import "../core/material";

// Theme specific variables - inherited from global variables

// background
$mbsc-material-page-background: $mbsc-page-background-light !default;
$mbsc-material-dark-page-background: $mbsc-page-background-dark !default;
// text
$mbsc-material-page-text: $mbsc-page-text-light !default;
$mbsc-material-dark-page-text: $mbsc-page-text-dark !default;

// add variablest to color maps
$mbsc-material-colors: map-merge($mbsc-material-colors, (
  'page-background': $mbsc-material-page-background,
  'page-text': $mbsc-material-page-text,
));
$mbsc-material-dark-colors: map-merge($mbsc-material-dark-colors, (
  'page-background': $mbsc-material-dark-page-background,
  'page-text': $mbsc-material-dark-page-text,
));

@mixin mbsc-material-page($theme, $params) {
  @include exports("page.#{$theme}.colors") {
    @include mbsc-material-common($theme, $params);

    $background: map-get($params, 'background');
    $accent: map-get($params, 'accent');
    $text: map-get($params, 'text');

    // get custom params
    $text-param: map-get($params, 'page-text');
    $background-param: map-get($params, 'page-background');
    // overwrite params with custom variables
    $background: if($background-param, $background-param, $background);
    $text: if($text-param, $text-param, if($background-param, get-contrast-color($background-param), lighten($text, 7%)));

    .mbsc-#{$theme} {
      &.mbsc-page {
        background-color: $background;
        color: $text;
      }

      a {
        color: $accent;
      }
    }
  }
}
